From 6109369e245845635ca04a7a44b685290a58b8f8 Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 14 Nov 2007 18:56:30 +0000 Subject: [PATCH] Add configure option to shrink the binary by excluding most formats. --- gpsbabel/Makefile.in | 20 +++++++------ gpsbabel/config.h.in | 3 ++ gpsbabel/configure | 30 +++++++++++++++++++- gpsbabel/configure.in | 14 +++++++++ gpsbabel/vecs.c | 66 ++++++++++++++++++++++++++----------------- 5 files changed, 98 insertions(+), 35 deletions(-) diff --git a/gpsbabel/Makefile.in b/gpsbabel/Makefile.in index f059f6326..73ef3cec2 100644 --- a/gpsbabel/Makefile.in +++ b/gpsbabel/Makefile.in @@ -42,21 +42,25 @@ INSTALL_DIR=$(DESTDIR)/$(PREFIX) # OTHER_ROOT=/opt/local # For DarwinPorts on OSX # OTHER_ROOT=/sw # Uncomment For Fink on OS X. -FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \ - gtm.o \ - gpsutil.o pcx.o cetus.o copilot.o gpspilot.o magnav.o \ - psp.o holux.o garmin.o tmpro.o tpg.o tpo.o \ - xcsv.o gcdb.o tiger.o internal_styles.o easygps.o quovadis.o \ +MINIMAL_FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin.o \ + garmin_tables.o internal_styles.o nmea.o kml.o + +ALL_FMTS=$(MINIMAL_FMTS) gtm.o gpsutil.o pcx.o cetus.o copilot.o \ + gpspilot.o magnav.o \ + psp.o holux.o tmpro.o tpg.o tpo.o \ + xcsv.o gcdb.o tiger.o easygps.o quovadis.o \ gpilots.o saroute.o navicache.o psitrex.o geoniche.o delgpl.o \ - ozi.o nmea.o text.o html.o palmdoc.o netstumbler.o hsa_ndv.o \ + ozi.o text.o html.o palmdoc.o netstumbler.o hsa_ndv.o \ igc.o brauniger_iq.o shape.o hiketech.o glogbook.o coastexp.o \ - vcf.o overlay.o kml.o google.o lowranceusr.o an1.o tomtom.o \ + vcf.o overlay.o google.o xhtmlent.o lowranceusr.o an1.o tomtom.o \ tef_xml.o maggeo.o pathaway.o vitosmt.o gdb.o bcr.o coto.o \ ignrando.o stmwpp.o msroute.o cst.o nmn4.o mag_pdb.o compegps.o \ yahoo.o unicsv.o wfff_xml.o garmin_txt.o axim_gpb.o gpssim.o \ wbt-200.o stmsdf.o gtrnctr.o dmtlog.o raymarine.o alan.o vitovtt.o \ ggv_log.o g7towin.o garmin_gpi.o lmx.o random.o xol.o dg-100.o +FMTS=@FMTS@ + FILTERS=position.o radius.o duplicate.o arcdist.o polygon.o smplrout.o \ reverse_route.o sort.o stackfilter.o trackfilter.o discard.o \ nukedata.o interpolate.o transform.o @@ -84,7 +88,7 @@ ZLIB=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o \ LIBOBJS = queue.o route.o waypt.o filter_vecs.o util.o vecs.o mkshort.o \ csv_util.o strptime.o grtcirc.o vmem.o util_crc.o xmlgeneric.o \ uuid.o formspec.o xmltag.o cet.o cet_util.o fatal.o rgbcolors.o \ - xhtmlent.o inifile.o garmin_fs.o gbsleep.o units.o @GBSER@ gbser.o \ + inifile.o garmin_fs.o gbsleep.o units.o @GBSER@ gbser.o \ gbfile.o parse.o \ $(PALM_DB) $(GARMIN) $(JEEPS) $(SHAPE) @ZLIB@ $(FMTS) $(FILTERS) OBJS = main.o globals.o $(LIBOBJS) @FILEINFO@ diff --git a/gpsbabel/config.h.in b/gpsbabel/config.h.in index 0e668d4f0..37c53f2bc 100644 --- a/gpsbabel/config.h.in +++ b/gpsbabel/config.h.in @@ -27,6 +27,9 @@ /* Define to 1 if you have the `sleep' function. */ #undef HAVE_SLEEP +/* 1 to enable as many formats as possible */ +#undef MAXIMAL_ENABLED + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT diff --git a/gpsbabel/configure b/gpsbabel/configure index cd43189b6..48e356eb5 100755 --- a/gpsbabel/configure +++ b/gpsbabel/configure @@ -669,6 +669,7 @@ CPP GREP EGREP PALM_DB_CMT +FMTS FILEINFO RC LIBUSBCONFIG @@ -1271,6 +1272,7 @@ Optional Features: --enable-shapefile=(yes)|no --enable-pdb=(yes)|no --enable-csv=(yes)|no + --enable-most=(yes)|no --enable-filters=(yes)|no --enable-efence=yes|(no) @@ -4190,6 +4192,31 @@ echo "${ECHO_T}yes" >&6; } echo "${ECHO_T}no" >&6; } fi +{ echo "$as_me:$LINENO: checking whether to support only minimal number of formats" >&5 +echo $ECHO_N "checking whether to support only minimal number of formats... $ECHO_C" >&6; } +# Check whether --enable-most was given. +if test "${enable_most+set}" = set; then + enableval=$enable_most; enable_most="$enableval" +else + enable_most="yes" +fi + + if test "$enable_most" != "no" ; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define MAXIMAL_ENABLED 1 +_ACEOF + + FMTS='$(ALL_FMTS)' + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + FMTS='$(MINIMAL_FMTS)' + fi + + { echo "$as_me:$LINENO: checking whether to support filters" >&5 echo $ECHO_N "checking whether to support filters... $ECHO_C" >&6; } # Check whether --enable-filters was given. @@ -5561,6 +5588,7 @@ CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim PALM_DB_CMT!$PALM_DB_CMT$ac_delim +FMTS!$FMTS$ac_delim FILEINFO!$FILEINFO$ac_delim RC!$RC$ac_delim LIBUSBCONFIG!$LIBUSBCONFIG$ac_delim @@ -5578,7 +5606,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 84; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 85; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/gpsbabel/configure.in b/gpsbabel/configure.in index 2d5aa62af..03f40f38a 100644 --- a/gpsbabel/configure.in +++ b/gpsbabel/configure.in @@ -88,6 +88,20 @@ AC_ARG_ENABLE(csv, AC_MSG_RESULT(no) fi +AC_MSG_CHECKING(whether to support only minimal number of formats) +AC_ARG_ENABLE(most, + [ --enable-most=[(yes)|no]], + [ enable_most="$enableval"],[enable_most="yes"]) + if test "$enable_most" != "no" ; then + AC_MSG_RESULT(yes) + AC_DEFINE(MAXIMAL_ENABLED, 1, [1 to enable as many formats as possible]) + FMTS='$(ALL_FMTS)' + else + AC_MSG_RESULT(no) + FMTS='$(MINIMAL_FMTS)' + fi + AC_SUBST(FMTS) + AC_MSG_CHECKING(whether to support filters) AC_ARG_ENABLE(filters, [ --enable-filters=[(yes)|no]], diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index 0e9d4beb8..ceabda250 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -165,24 +165,43 @@ vecs_t vec_list[] = { "Magellan SD files (as for eXplorist)", "upt" }, + { + &garmin_vecs, + "garmin", + "Garmin serial/USB protocol", + NULL + }, { &mapsend_vecs, "mapsend", "Magellan Mapsend", NULL }, - { - &pcx_vecs, - "pcx", - "Garmin PCX5", - "pcx" - }, { &mps_vecs, "mapsource", "Garmin MapSource - mps", "mps" }, + { + &nmea_vecs, + "nmea", + "NMEA 0183 sentences", + NULL + }, + { + &kml_vecs, + "kml", + "Google Earth (Keyhole) Markup Language", + "kml" + }, +#if MAXIMAL_ENABLED + { + &pcx_vecs, + "pcx", + "Garmin PCX5", + "pcx" + }, { &gpsutil_vecs, "gpsutil", @@ -227,12 +246,6 @@ vecs_t vec_list[] = { "pdb" }, #endif /* PDBFMTS_ENABLED */ - { - &garmin_vecs, - "garmin", - "Garmin serial/USB protocol", - NULL - }, { &holux_vecs, "holux", @@ -349,12 +362,6 @@ vecs_t vec_list[] = { "OziExplorer", NULL }, - { - &nmea_vecs, - "nmea", - "NMEA 0183 sentences", - NULL - }, { &text_vecs, "text", @@ -429,12 +436,6 @@ vecs_t vec_list[] = { "Garmin Logbook XML", "xml" }, - { - &kml_vecs, - "kml", - "Google Earth (Keyhole) Markup Language", - "kml" - }, { &vcf_vecs, "vcard", @@ -525,6 +526,7 @@ vecs_t vec_list[] = { "IGN Rando track files", "rdn" }, +#if CSVFMTS_ENABLED { &stmsdf_vecs, "stmsdf", @@ -537,6 +539,7 @@ vecs_t vec_list[] = { "Suunto Trek Manager (STM) WaypointPlus files", "txt" }, +#endif // CSVFMTS_ENABLED { &msroute_vecs, "msroute", @@ -695,6 +698,7 @@ vecs_t vec_list[] = { "GlobalSat DG-100/BT-335 Download", NULL }, +#endif // MAXIMAL_ENABLED { NULL, NULL, @@ -861,7 +865,9 @@ find_vec(char *const vecname, char **opts) if (global_opts.debug_level >= 1) disp_vec_options(vec->name, vec->vec->args); +#if CSVFMTS_ENABLED xcsv_setup_internal_style( NULL ); +#endif // CSVFMTS_ENABLED xfree(v); return vec->vec; @@ -913,8 +919,9 @@ find_vec(char *const vecname, char **opts) if (global_opts.debug_level >= 1) disp_vec_options(svec->name, vec_list[0].vec->args); - +#if CSVFMTS_ENABLED xcsv_setup_internal_style(svec->style_buf); +#endif // CSVFMTS_ENABLED xfree(v); @@ -1008,8 +1015,12 @@ sort_and_unify_vecs(int *ctp) /* Get a count from both the vec (normal) and the svec (csv) lists */ +#if CSVFMTS_ENABLED extern size_t nstyles; - vc = sizeof vec_list / sizeof vec_list[0] -1 + nstyles; + vc = sizeof vec_list / sizeof vec_list[0] - 1 + nstyles; +#else + vc = sizeof vec_list / sizeof vec_list[0] - 1; +#endif // CSVFMTS_ENABLED svp = xcalloc(vc, sizeof(style_vecs_t *)); @@ -1021,6 +1032,7 @@ sort_and_unify_vecs(int *ctp) } } +#if CSVFMTS_ENABLED /* Walk the style list, parse the entries, dummy up a "normal" vec */ for (svec = style_list; svec->name; svec++, i++) { xcsv_read_internal_style(svec->style_buf); @@ -1055,6 +1067,8 @@ sort_and_unify_vecs(int *ctp) svp[i]->desc = xcsv_file.description; svp[i]->parent = "xcsv"; } +#endif // CSVFMTS_ENABLED + /* Now that we have everything in an array, alphabetize them */ qsort(svp, vc, sizeof(*svp), alpha); -- 2.30.2